import 'package:flutter/material.dart';
import '../common_widget/hexcolor.dart';

class MinePage extends StatefulWidget {
  const MinePage({Key? key}) : super(key: key);

  @override
  _MinePageState createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  List menuTitles = [
    '实名认证',
    '定位',
    '账号安全',
    '帮助与反馈',
    '关于',
    '通用',
  ];
  List menuIcons = [
    "images/mine_icons0.png",
    "images/mine_icons1.png",
    "images/mine_icons2.png",
    "images/mine_icons3.png",
    "images/mine_icons4.png",
    "images/mine_icons5.png",
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.separated(
          itemBuilder: (context, index) {
            if (index == 0) {
              return Column(
                children: [
                  Padding(
                      padding: const EdgeInsets.all(8),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Container(
                            margin: const EdgeInsets.only(left: 12),
                            child: const Text(
                              '我的',
                              style: TextStyle(
                                  fontSize: 20, fontWeight: FontWeight.bold),
                            ),
                          ),
                          IconButton(
                            icon: Image.asset("images/mine_replace.png"),
                            onPressed: () {
                              // 修改 state 内部变量, 且需要界面内容更新, 需要使用 setState()
                              setState(() {});
                            },
                          )
                        ],
                      )),
                  Padding(
                      padding: const EdgeInsets.all(8),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Row(
                            children: [
                              Container(
                                height: 100,
                                margin: const EdgeInsets.all(12),
                                child: Image.asset("images/avair_icon.png",
                                    width: 72, height: 72),
                              ),
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: const [
                                  Text('陈思杰'),
                                  Text('176****5401'),
                                ],
                              ),
                            ],
                          ),
                          Container(
                            child: const Icon(
                              Icons.arrow_forward_ios,
                              size: 15,
                            ),
                          ),
                        ],
                      ))
                ],
              );
            }
            index -= 1;
            return ListTile(
              leading: Image.asset(menuIcons[index], width: 32, height: 32),
              //左图标
              title: Text(
                menuTitles[index],
                style: const TextStyle(fontSize: 16),
              ),
              //中间标题
              trailing: const Icon(
                Icons.arrow_forward_ios,
                size: 15,
              ),
            );
          },
          separatorBuilder: (context, index) {
            return const Divider();
          }, //分隔线
          itemCount: menuTitles.length + 1),
    );
  }

  Widget buildForgetPasswordText(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.only(top: 8),
      child: Align(
        alignment: Alignment.centerRight,
        child: TextButton(
          onPressed: () {
            // Navigator.pop(context);
            // ignore: avoid_print
            print("忘记密码");
          },
          child: const Text("忘记密码？",
              style: TextStyle(fontSize: 14, color: Colors.grey)),
        ),
      ),
    );
  }
}
